from django.urls import path
from . import views

app_name = 'data_service'

urlpatterns = [
    # 数据源
    path('sources/', views.DataSourceListView.as_view(), name='data_sources'),
    
    # 同步任务
    path('sync/tasks/', views.DataSyncTaskListView.as_view(), name='sync_tasks'),
    path('sync/create/', views.create_sync_task, name='create_sync_task'),
    path('sync/status/', views.sync_status, name='sync_status'),
    
    # 同步日志
    path('sync/logs/', views.DataSyncLogListView.as_view(), name='sync_logs'),
    
    # 基金数据 - 具体路径必须在通用路径之前
    path('funds/list-for-select/', views.fund_list_for_select, name='fund_list_for_select'),
    path('funds/search/', views.fund_search, name='fund_search'),
    path('funds/statistics/', views.fund_statistics, name='fund_statistics'),
    path('funds/statistics-test/', views.fund_statistics_test, name='fund_statistics_test'),
    path('funds/statistics-django/', views.fund_statistics_django, name='fund_statistics_django'),
    path('funds/export/', views.export_fund_data, name='fund_export'),
    path('funds/<str:fund_code>/detail-info/', views.fund_detail_info, name='fund_detail_info'),
    path('funds/<str:fund_code>/nav-history-chart/', views.fund_nav_history_chart, name='fund_nav_history_chart'),
    path('funds/<str:fund_code>/performance/', views.fund_performance, name='fund_performance'),
    path('funds/<str:fund_code>/', views.FundDataDetailView.as_view(), name='fund_detail'),
    path('funds/', views.FundDataListView.as_view(), name='fund_list'),
    
    # 基金净值
    path('funds/<str:fund_code>/net-values/', views.FundNetValueListView.as_view(), name='fund_net_values'),
    path('net-values/', views.FundNetValueSearchView.as_view(), name='net_values_search'),
    
    # 市场数据
    path('market/', views.MarketDataListView.as_view(), name='market_data'),
    path('market/indicators/', views.market_indicators, name='market_indicators'),
    
    # 数据下载相关API
    path('download/fund-list/', views.download_fund_list, name='download-fund-list'),
    path('download/fund-details/', views.download_fund_details, name='download-fund-details'),
    path('download/fund-nav/', views.download_fund_nav, name='download-fund-nav'),
    path('download/fund-basic-info/', views.download_fund_basic_info, name='download-fund-basic-info'),
    # path('download/open-fund-info/', views.download_open_fund_info, name='download-open-fund-info'),
    path('download/progress/', views.download_progress, name='download-progress'),
    path('download/stop/', views.stop_download_task, name='stop_download_task'),
    
    # 数据库检查和清理API
    path('check/database-data/', views.check_database_data, name='check-database-data'),
    path('clear/fund-data/', views.clear_fund_data, name='clear-fund-data'),
    
    # 数据更新相关API
    path('update/fund_list/', views.update_fund_list, name='update-fund-list'),
    path('update/fund_detail/', views.update_fund_detail, name='update-fund-detail'),
    path('update/fund_nav/', views.update_fund_nav, name='update-fund-nav'),
    
    # 基金下载相关API
    path('fund-download/stop/', views.stop_fund_download, name='stop-fund-download'),
    path('fund-download/status/', views.get_fund_download_status, name='get-fund-download-status'),
    
    # 基金详细信息下载新功能API
    path('fund-detail/stored-count/', views.get_stored_fund_count, name='get-stored-fund-count'),
    path('fund-detail/continue-download/', views.continue_fund_detail_download, name='continue-fund-detail-download'),
    
    # 基金净值相关API
    path('sync/fund-data/', views.sync_fund_data, name='sync-fund-data'),
    path('funds/<str:fund_code>/net-value/latest/', views.fund_net_value_latest, name='fund-net-value-latest'),
    path('funds/<str:fund_code>/net-value/refresh/', views.refresh_fund_net_value, name='refresh-fund-net-value'),
    
    # 基金净值下载API
    path('fund-nav-download/start/', views.start_fund_nav_download, name='start-fund-nav-download'),
    path('fund-nav-download/stop/', views.stop_fund_nav_download, name='stop-fund-nav-download'),
    path('fund-nav-download/continue/', views.continue_fund_nav_download, name='continue-fund-nav-download'),
    path('fund-nav-download/status/', views.get_fund_nav_download_status, name='get-fund-nav-download-status'),
    path('fund-nav-download/statistics/', views.get_fund_nav_download_statistics, name='get-fund-nav-download-statistics'),
    path('fund-nav-download/reset/', views.reset_fund_nav_download, name='reset_fund_nav_download'),
    path('fund-nav-download/restart/', views.restart_fund_nav_download, name='restart_fund_nav_download'),
    
    # 基金净值更新API
    path('fund-nav-update/start/', views.start_fund_nav_update, name='start-fund-nav-update'),
    path('fund-nav-update/stop/', views.stop_fund_nav_update, name='stop-fund-nav-update'),
    path('fund-nav-update/status/', views.get_fund_nav_update_status, name='get-fund-nav-update-status'),
    path('fund-nav-update/statistics/', views.get_fund_nav_update_statistics, name='get-fund-nav-update-statistics'),
    
    # 基金排行数据相关
    path('test-debug/', views.test_debug_endpoint, name='test_debug_endpoint'),
    path('fund-nav-ranking-stats/', views.fund_nav_ranking_stats, name='fund_nav_ranking_stats'),
    path('fund-nav-ranking-stats/sync/', views.sync_fund_nav_ranking, name='sync_fund_nav_ranking'),
    path('fund-nav-ranking-stats/sync/status/', views.sync_fund_nav_ranking_status, name='sync_fund_nav_ranking_status'),
    
    # 基金净值详细数据
    path('fund-nav-detail/', views.FundNavDetailListView.as_view(), name='fund_nav_detail_list'),
    path('fund-nav-detail/latest/', views.final_fund_scraper_latest, name='fund_nav_detail_latest'),
    path('fund-nav-detail/<str:fund_code>/history/', views.fund_nav_detail_history, name='fund_nav_detail_history'),
    
    # 基金净值历史数据 - 使用FundNavAPI
    path('fund-nav-api/<str:fund_code>/history/', views.fund_nav_history_api, name='fund_nav_history_api'),
]